<!--
 * @Author: bln
 * @Date: 2024-2-23 00:00:00
 * @FilePath: \zmglpt-ui-mobile-v1.1\dev\pages\retailer\retailerInfo\retailerItem\componets\purchaseDetail.vue
 * @Description: 零售户详情 - 进货记录详情
-->
<template>
  <view class="page">
		<!-- #ifndef H5-DINGDING -->
		<theme-navbar :is-white="false" title="进货记录详情" :custom-back="goBack" style="z-index: 99999"></theme-navbar>
		<!-- #endif -->
    <view class="content">
      <u-table font-size="26" style="border-left: none;">
          <u-tr class="u-tr border-left">
            <u-th width="10%">序号</u-th>
            <u-th width="50%">卷烟品规</u-th>
            <u-th width="20%">数量</u-th>
            <u-th width="20%">金额</u-th>
          </u-tr>
          <mescroll-list
            :i="0"
            :index="0"
            ref="mescrollItem"
            :init-load="false"
            :loadData="loadData"
            :normalScrollView="true"
            :height="getListViewHeight()"
          >
            <u-tr class="u-tr border-left"  slot-scope="d">
              <u-td width="10%" class="u-col-center">{{ d.index + 1 }}</u-td>
              <u-td width="50%">{{ d.data.productName }}</u-td>
              <u-td width="20%">{{ d.data.saleQty }}</u-td>
              <u-td width="20%">{{ d.data.saleMoney }}</u-td>
            </u-tr>
          </mescroll-list>
      </u-table>
    </view>
  </view>
</template>

<script>
import mescrollList from '@/components/mescroll_list.vue'
import certificateService from '@/service/certificate/certificate.service.js'

export default {
  components: { mescrollList },
  data () {
    return {
      dataSource: []
    }
  },
  onLoad (opt) {
    this.sellNo = opt.sellNo
  },
  methods: {
    getListViewHeight() {
      let p = this.$u.sys().windowHeight - 44 - uni.upx2px(180) - this.$u.sys().statusBarHeight + 'px';
      return p;
    },
    // 列表数据初始化
    loadData(page) {
      return certificateService.dailyOrderDetails({
        page: page.num,
        limit: page.size,
        sellNo: this.sellNo
      }).then(res => {
        if (res.success) {
          const total = {
            productName: "合计",
            saleMoney: 0,
            saleQty: 0
          }
          res.bean.map((item) => {
            total.saleMoney += Number(item.saleMoney)
            total.saleQty += Number(item.saleQty)
          });
          total.saleMoney = total.saleMoney.toFixed(2)
          res.data = [...res.bean, total ]
        }
        return res
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.page {
	padding: 0;
}
.content {
	padding-left: $cm-content-paddng-row;
	padding-right: $cm-content-paddng-row;
	padding-top: $cm-conent-padding-column;
	padding-bottom: 70px;
}
/deep/.u-td {
	height: auto;
}
</style>

